package com.credit.jumu.playcard.fragment;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.credit.jumu.playcard.R;
import com.credit.jumu.playcard.utils.LogUtils;

/**
 * Created by jpeng on 16-11-14.
 */
public class BillTabFragment extends Fragment implements View.OnClickListener {
	private BillFragmentController billFragmentController;
	TextView billfragment1, billfragment2, billfragment3;
	View line1, line2, line3;

	@Override
	public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
		View view = inflater.inflate(R.layout.fragment_billtab, null);
		initView(view);
		LogUtils.println("BillTabFragment" + "onCreateView");
		//		billFragmentController = BillFragmentController.getInstance(this, R.id.billfeagment);
		billFragmentController = new BillFragmentController(this, R.id.billfeagment);
		billFragmentController.showFragment(0);
		return view;
	}

	@Override
	public void onResume() {
		super.onResume();
		LogUtils.println("BillTabFragment" + "onResume");


	}

	@Override
	public void onPause() {
		super.onPause();
		LogUtils.println("BillTabFragment" + "onPause");
	}

	@Override
	public void onStart() {
		super.onStart();
		LogUtils.println("BillTabFragment" + "onStart");
	}

	@Override
	public void onStop() {
		super.onStop();
		LogUtils.println("BillTabFragment" + "onStop");
	}

	@Override
	public void onDestroy() {
		super.onDestroy();
		LogUtils.println("BillTabFragment" + "onDestroy");
	}

	private void initView(View view) {
		billfragment1 = view.findViewById(R.id.billfragment1);
		billfragment2 = view.findViewById(R.id.billfragment2);
		billfragment3 = view.findViewById(R.id.billfragment3);
		line1 = view.findViewById(R.id.line1);
		line2 = view.findViewById(R.id.line2);
		line3 = view.findViewById(R.id.line3);
		billfragment1.setOnClickListener(this);
		billfragment2.setOnClickListener(this);
		billfragment3.setOnClickListener(this);
	}

	@Override
	public void onClick(View v) {
		switch (v.getId()) {
			case R.id.billfragment1:
				billFragmentController.showFragment(0);
				line1.setVisibility(View.VISIBLE);
				line2.setVisibility(View.INVISIBLE);
				line3.setVisibility(View.INVISIBLE);
				billfragment1.setTextColor(getResources().getColor(R.color.app_them));
				billfragment2.setTextColor(getResources().getColor(R.color.cardcoloer));
				billfragment3.setTextColor(getResources().getColor(R.color.cardcoloer));
				break;
			case R.id.billfragment2:
				billFragmentController.showFragment(1);
				line1.setVisibility(View.INVISIBLE);
				line2.setVisibility(View.VISIBLE);
				line3.setVisibility(View.INVISIBLE);
				billfragment2.setTextColor(getResources().getColor(R.color.app_them));
				billfragment1.setTextColor(getResources().getColor(R.color.cardcoloer));
				billfragment3.setTextColor(getResources().getColor(R.color.cardcoloer));
				break;
			case R.id.billfragment3:
				billFragmentController.showFragment(2);
				line1.setVisibility(View.INVISIBLE);
				line2.setVisibility(View.INVISIBLE);
				line3.setVisibility(View.VISIBLE);
				billfragment3.setTextColor(getResources().getColor(R.color.app_them));
				billfragment2.setTextColor(getResources().getColor(R.color.cardcoloer));
				billfragment1.setTextColor(getResources().getColor(R.color.cardcoloer));
				break;
		}

	}
}